/**
 * 
 */
package lu.med.praxiswahl.wahlumed.client.briefe;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import lu.med.praxiswahl.wahlumed.model.beans.DoctorsTBL;

/**
 * @author PatrickPierre
 * 
 */
public class DoctorListCellRenderer extends JLabel implements ListCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7357255506233723594L;

	private Color grey = new Color(240, 240, 240);
	private Font bold = new Font("Verdana", Font.BOLD, 11);

	public DoctorListCellRenderer() {

	}

	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {

		this.setOpaque(true);
		DoctorsTBL doc = (DoctorsTBL) value;

		String name = doc.getNachname();

		String vorname = doc.getVorname();
		String gebiet = doc.getFachgebiet();
		String adress = doc.getAdresse();

		this.setText("<html><b>" + name + " " + vorname + "</b>  -  <i>"
				+ gebiet + "</i> <br />" + adress + "</html>");
		list.setBackground(Color.LIGHT_GRAY);
		this.setFont(new Font("Verdana", Font.PLAIN, 11));

		if (isSelected) {
			this.setBackground(Color.blue);
			this.setForeground(Color.WHITE);
			setFont(bold);
			this.setBorder(BorderFactory.createLineBorder(Color.blue));
		} else {
			this.setBackground(Color.white);
			this.setForeground(Color.black);
			this.setBorder(null);
		}

		if (index % 2 == 0) {
			this.setForeground(list.getForeground());
			this.setBackground(list.getBackground());
		} else {
			
			this.setForeground(list.getForeground());
			this.setBackground(grey);
		}

		return this;
	}

}
